package com.wn.class30.service.impl;

import com.wn.class30.entity.UserAddress;
import com.wn.class30.entity.UserAddressExample;
import com.wn.class30.mapper.UserAddressDao;

import com.wn.class30.service.UserAddressService1;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserAddressServiceImpl1 implements UserAddressService1 {
    @Resource
    private UserAddressDao userAddressDao;
    @Override
    public List<UserAddress> queryAddressByUserid(Integer userid) throws Exception {
        UserAddressExample userAddressExample = new UserAddressExample();
        UserAddressExample.Criteria criteria = userAddressExample.createCriteria();
        criteria.andUserIdEqualTo(userid);
        List<UserAddress> userAddresses = userAddressDao.selectByExample(userAddressExample);
        return userAddresses;
    }

    @Override
    public void updateDefaultAddressByUserId(Integer userid, Integer addressid) throws Exception {
        UserAddress userAddress = new UserAddress();
        userAddress.setUserAddressId(addressid);
        userAddress.setUserId(userid);
        int i = userAddressDao.updateDefaultAddressByUserId(userAddress);
    }
}
